home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _C810A4A4F2E945578CE3698FD767D7B5 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.9 KB  |  49 lines

  1.  
  2.       #include "../CGVPMacro.csi"
  3.  
  4.       MainInput { uniform sampler2D baseMap : texunit0,
  5.                   uniform sampler2D bumpMap : texunit1,
  6.                   uniform sampler2D specPowMap : texunit3,
  7.                   uniform float4 Diffuse,
  8.                     uniform float4 Specular,
  9.                     uniform float4 AmbientEmissive,
  10.                     uniform float  SpecPower }
  11.       DeclarationsScript
  12.       {
  13.         OUT_T0_T1_T2_T3_C0
  14.         FOUT
  15.       }
  16.       CoreScript
  17.       {
  18.         // load the decal
  19.         float4 decalColor = tex2D(baseMap, IN.Tex0.xy);
  20.         // load the bump normal
  21.         float4 bumpNormal = 2*(tex2D(bumpMap, IN.Tex1.xy)-0.5);
  22.         // compute texCoord(NdotH, 0) and use it to look up NdotH^power in the power texture
  23.         // This should create a texm3x2tex instruction for ps_1_1 equivalent to the ps_1_1
  24.         // builtin tex2D_dp3x2 (which is not supported in any other profile):
  25.         //    float4 NdotL_NdotH = tex2D_dp3x2(specPowMap, IN.Tex2, bumpNormal);
  26.         float2 texCoord = float2(
  27.             dot(IN.Tex2.xyz, bumpNormal.xyz),
  28.             dot(IN.Tex3.xyz, bumpNormal.xyz));
  29.         float4 NdotL_NdotH = tex2D(specPowMap, texCoord);
  30.  
  31.         // grab the attenuation factor out of the specular iterator
  32.         float3 attenuation = IN.Color.aaa;
  33.         //float selfShadow;
  34.         // modulate both NdotL and NdotH by the self-shadow and attenuation terms
  35.         NdotL_NdotH.xyz *= attenuation;
  36.         NdotL_NdotH.w *= attenuation.x;
  37.  
  38.         // to match vertex pipeline, diffuse = (matDif * difIntensity + matAmbient) * decalColor
  39.         float4 dif;
  40.         dif.rgb = (Diffuse.rgb*NdotL_NdotH.xyz+AmbientEmissive.rgb) * decalColor.rgb;
  41.         dif.a = decalColor.a;
  42.  
  43.         // compute the specular color
  44.         float4 spec = Specular * NdotL_NdotH.wwww * 2;
  45.         
  46.         // finally add them all together
  47.         OUT.Color = dif + spec;
  48.       }
  49.